package com.ruoyi.web.controller.shopping;

import com.ruoyi.system.domain.shopping.User;
import com.ruoyi.system.service.shopping.UserService;
import com.ruoyi.system.view.common.Result;
import com.ruoyi.web.controller.shopping.common.BaseContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/xiaomi/v2/ms/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/info")
    public Result<User> user() {
        User user = userService.selectUser(BaseContext.getId());
        return Result.success(user, "查询成功");
    }

    @PostMapping("/login")
    public Result login(@RequestBody User user) {
        return userService.login(user);
    }

    @PostMapping("/register")
    public Result register(@RequestBody User user) {
        return userService.register(user);
    }
}
